import type { App } from 'vue'
import { setupHasRole } from '@/directives/permission/hasRole'
import { setupHasPermi } from '@/directives/permission/hasPermi'

/**
 * 安装v-hasRole、v-hasPermi指令
 */
export const setupAuth = (app: App<Element>) => {
  setupHasRole(app)
  setupHasPermi(app)
}

/**
 * 安装v-mountedFocus指令
 * @param app
 */
export const setupMountedFocus = (app: App<Element>) => {
  app.directive('mountedFocus', {
    mounted(el) {
      el.focus()
    }
  })
}

export const setupDirectives = (app: App<Element>) => {
  setupMountedFocus(app)
  setupAuth(app)
}
